package com.cloudbroker.bcs.platform.ltb.middle.mybatis;

/**
 * Created by zhaosh19213 on 2016/8/18.
 */
public class ShardContext extends ShardInfo {
    /**
     * 线程安全分库查询类.
     */
    private static final ThreadLocal<ShardContext> SHARD_CONTEXT = new ThreadLocal<ShardContext>();

    /**
     * 取得当前的参数.
     */
    public static ShardContext getShardContext() {
        ShardContext context = SHARD_CONTEXT.get();
        if (null == context) {
            context = new ShardContext();
            SHARD_CONTEXT.set(context);
        }
        return context;
    }

    /**
     * 移除当前分页参数.
     */
    public static void removeShardContext() {
        SHARD_CONTEXT.remove();
    }

    /**
     * 判断Pagination是否存在.
     */
    public static boolean isExistShardContext() {
        ShardContext context = SHARD_CONTEXT.get();
        if (null == context) {
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        String  s = "sadas.queyaaa";
        System.out.println(s.matches(".*query.*"));
    }
}
